package net.udp;

import java.io.IOException;
import java.net.SocketAddress;
import java.net.SocketException;

public class NatScan extends UdpSocket {

	public NatScan(int bindPort) throws SocketException {
		super(bindPort);
	}
	
	public void start() throws Exception{
		this.receive();
		
		byte[] buf = "888888".getBytes();
		for(int i=1024; i<65535; i++){
			this.setDestAddress("180.166.48.210", i);
			this.send(buf, 0, buf.length);
			Thread.sleep(0);
		}
		System.out.println("send over.");
	}
	
	protected void handle(SocketAddress socketAddress, byte[] buf, int offset, int length){
		String str = new String(buf, offset, length);
		System.out.println(str);
		if(str.equals("888888")){
			System.out.println(socketAddress);
		}
	}
	

	public static void main(String args[]) throws Exception{
		NatScan ns = new NatScan(5555);
		ns.start();
	}
}
